<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style type="text/css">
        /* setInterval: 班级回答问题*/
        #tab{
            margin:0px auto ;
            width: 700px;
            height: 300px;
        }

        td{
            border: solid 2px blue;
            width: 100px;
            height: 100px;
            text-align: center;
            font-weight: bold;
        }
    </style>
    <script>
        function fn(){
            var num = parseInt(Math.random() * 41 + 1);
            var tdObj = document.getElementById('td' + num);
            tdObj.style.backgroundColor = 'red';
            document.getElementById('sp').innerText = '抽中的同学是:' + tdObj.innerText; 
        }
        function start(){
            for(let i = 1; i <= 9; i++){
                var tdObj = document.getElementById('td' + i);
                tdObj.style.backgroundColor = 'white';
            }
            document.getElementById('sp').innerText = '正在抽取中...'
            setTimeout(fn,3000 );
        }
    </script>
    </head>
<body>
            <div id="btn" style="text-align: center; margin:50px">
                <button onclick="start()">点击抽奖</button>
                <span id="sp"></span>
            </div>
            <table id="tab">
                <tr> 
                    <td id="tid">郑玮喆</td>
                    <td id="tid">庄云</td>
                    <td id="tid">廖治先</td>
                    <td id="tid">郑文源</td>
                    <td id="tid">戴俊锋</td>
                    <td id="tid">陈昊童</td>
                    <td id="tid">谢金金</td>
                </tr>
                <tr> 
                    <td id="tid">占志新</td>
                    <td id="tid">张淑芳</td>
                    <td id="tid">刘永潘</td>
                    <td id="tid">廖柏成</td>
                    <td id="tid">郑宗帅</td>
                    <td id="tid">李韦峰</td>
                    <td id="tid">吴欣燕</td>
                </tr>
                <tr> 
                    <td id="tid">陈梅香</td>
                    <td id="tid">陈立智</td>
                    <td id="tid">袁贵森</td>
                    <td id="tid">赵浩敏</td>
                    <td id="tid">林世涛</td>
                    <td id="tid">罗启恒</td>
                    <td id="tid">卢国建</td>
                </tr>
                <tr> 
                    <td id="tid">黄柱菘</td>
                    <td id="tid">陈鹏</td>
                    <td id="tid">张耀仁</td>
                    <td id="tid">陈华伟</td>
                    <td id="tid">张正豪</td>
                    <td id="tid">韦仲晓</td>
                    <td id="tid">黄富贵</td>
                </tr>
                <tr> 
                    <td id="tid">陆建锋</td>
                    <td id="tid">曾德森</td>
                    <td id="tid">吴文龙</td>
                    <td id="tid">陆利群</td>
                    <td id="tid">黄雄</td>
                    <td id="tid">王世财</td>
                    <td id="tid">张先杰</td>
                </tr>
                <tr> 
                    <td id="tid">胡基耀</td>
                    <td id="tid">马鑫涛</td>
                    <td id="tid">李涛</td>
                    <td id="tid">杨凌翔</td>
                    <td id="tid">罗此东</td>
                    <td id="tid">唐皓颖</td>
                    <td id="tid">白婉婷</td>
                </tr>
            </body>
            </table>
</html>